<template>
    <div>
        <span>获取验证码({{ count }})</span>
    </div>
</template>

<script setup lang="ts">
import { ref, computed,watch } from 'vue'

let props = defineProps(['flag']);
let $emit = defineEmits(['backEmit'])

let count = ref(5)

watch(
    () => props.flag,
    () => { 
        let timer = setInterval(() => {
            count.value--
            if (count.value == 0) {
                console.log(2222);
                $emit('backEmit', true)
                clearInterval(timer)
                
            }
        }, 1000)
    
    }, {
    immediate:true
})







</script>

<style scoped lang="scss">

</style>